package gui;

import java.awt.Dimension;
import java.awt.EventQueue;
import java.util.LinkedList;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;

import mail.Mail;
import mail.MyModelEmail;
import contacts.Owner;

/**
 * Prototyping Klasse - unbenutzt
 * 
 * @author Michi
 * 
 */
public class MailList extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6632172791721074619L;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MailList frame = new MailList();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public MailList() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);

		JPanel jp = new JPanel();
		jp.setMinimumSize(new Dimension(252, 100));
		jp.setSize(new Dimension(252, 30));
		jp.setPreferredSize(new Dimension(252, 30));
		JScrollPane sp = new JScrollPane(jp);
		sp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		setContentPane(sp);

		Owner owner = new Owner("Michael", "Brandt");
		owner.setEmail("testmail@brotek.eu");
		owner.setImapServer("imap.brotek.eu");
		owner.setMailPass("test123");
		owner.setSmtpServer("smtp.brotek.eu");
		owner.setProvider("imap");

		Owner test1 = new Owner("Michael", "Brandt");
		test1.setEmail("testmailsopra@gmail.com");
		test1.setImapServer("imap.gmail.com");
		test1.setMailPass("sopra1213");
		test1.setSmtpServer("smtp.brotek.eu");
		test1.setProvider("imaps");

		MyModelEmail mme = new MyModelEmail();
		LinkedList<Mail> ll = mme.listInbox();

		int a = 252;
		int b = 100;
		for (int i = 0; i < ll.size(); i++) {
			MailPanel mp = new MailPanel();
			mp.setMail(ll.get(i));
			mp.setFrom(ll.get(i).getFrom());
			mp.setBetreff(ll.get(i).getBetreff());
			mp.setContentText(ll.get(i).getText());
			jp.add(mp);

			jp.setPreferredSize(new Dimension(a, ((i + 1) * b)));

		}
		sp.setVisible(true);

	}
}
